<!DOCTYPE html>
<meta charset="utf-8">
<title>Named access on the window object - Document without window</title>
<link rel="author" title="Matthew Phillips" href="mailto:matthew@matthewphillips.info">
<link rel="help" href="https://html.spec.whatwg.org/#named-access-on-the-window-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>

<script>
"use strict";

test(() => {
  const doc = document.implementation.createHTMLDocument();
  // Test case prerequisite
  assert_equals(doc.defaultView, null);

  const img = doc.createElement("img");
  img.setAttribute("id", "foo");
  doc.body.appendChild(img);
  assert_true(Boolean(img.parentNode));

  img.setAttribute("id", "bar");
  assert_equals(img.getAttribute("id"), "bar");

  doc.body.removeChild(img);
  assert_false(Boolean(img.parentNode));
}, "A document without a Window should not cause errors");
</script>
</body>
